﻿using MyCommunity.Models;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System;
using System.Data.Entity;
using System.Collections.Generic;


public class EventViewModel
{
    private Event obj;

    public EventViewModel() {
        this.obj = new Event();
    }

    public EventViewModel(Event obj)
    {
        this.Id = obj.Id;
        this.Title = obj.Title;
        this.Description = obj.Description;
        this.Addresse = obj.Addresse;
        this.ZipCode = (short)obj.ZipCode;
        this.City = obj.City;
        this.StartDate = obj.StartDate;
        this.EndDate = obj.EndDate;
    }

    public void ApplyChanges(Event obj)
    {
        obj.Addresse = this.Addresse;
        obj.City = this.City;
        obj.Description = this.Description;
        obj.EndDate = this.EndDate;
        obj.StartDate = this.StartDate;
        obj.Title = this.Title;
        obj.ZipCode = this.ZipCode;
    }

    public void SetAttendance(List<UserEventAttendance> attendance)
    {
        _attendance = attendance;
    }

    public List<UserEventAttendance> UserEventAttendance { get { return _attendance; } }
    private List<UserEventAttendance> _attendance;
    public List<Event> events { get; set; }

    public void SetRole(bool isAdmin)
    {
        _isAdmin = isAdmin;
    }

    public bool isAdmin { get { return _isAdmin; } }
    private bool _isAdmin;

    public int Id { get; set; }

    [Required]
    public string Title { get; set; }

    [Required]
    public string Description { get; set; }

    [Required]
    public string Addresse { get; set; }

    [Required]
    public short ZipCode { get; set; }

    [Required]
    public string City { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    [Display(Name = "Beginn")]
    [RegularExpression(@"^(([0-2]\d|[3][0-1])\.([0]\d|[1][0-2])\.[1-2][0-9]\d{2})\s[0-2][0-9]\:[0-6][0-9]\:[0-6][0-9]$", ErrorMessage = "Es muss sich um ein gültiges Datum handeln!")]
    public DateTime StartDate { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    [RegularExpression(@"^(([0-2]\d|[3][0-1])\.([0]\d|[1][0-2])\.[1-2][0-9]\d{2})\s[0-2][0-9]\:[0-6][0-9]\:[0-6][0-9]$", ErrorMessage = "Es muss sich um ein gültiges Datum handeln!")]
    [Display(Name = "Ende")]
    public DateTime EndDate { get; set; }
}